package digital.store.springmvc.service;

import java.util.Collection;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import digital.store.springmvc.dao.UserDao;
import digital.store.tutorial.springmvc.model.User;

@Service
@Transactional
public class UserService {
    @Autowired
    private UserDao userDao;
    
    @Transactional
    public void saveOrUpdate(User user) {
    	userDao.saveOrUpdate(user);
    }
    
    @Transactional
    public void delete(Long userId) {
        userDao.delete(userId);
    }
    
    
    public Collection<User> findAll() {
        return userDao.findAll();
    }
    
 
    public User findById(Long userId) {
        return userDao.findById(userId);
    }
   
    public User findByName(String firstName) {
    	return userDao.findByName(firstName);
    }
    
    public User checkUser(String username,String password){
    	return userDao.checkUser(username, password);
    }
    
}

